﻿<DemoPageSectionComponent Id="FileManagement-Upload-ChunkUpload">
    @inject NavigationManager NavigationManager

    <div class="upload-container">
        <div style="@(SelectedFilesCount > 0 ? "display: none" : string.Empty)">
            <span class="drop-file-icon mb-3"></span>
            <span class="mb-3">Click the Select File button to select a file</span>
        </div>
        <DxUpload Name="myFile"
                  ChunkSize="200000"
                  MaxFileSize="15000000"
                  UploadUrl="@GetUploadUrl("api/UploadChunks/Upload/")"
                  SelectedFilesChanged="@SelectedFilesChanged">
        </DxUpload>
    </div>

    @code {
        int SelectedFilesCount { get; set; }

        protected void SelectedFilesChanged(IEnumerable<UploadFileInfo> files) {
            SelectedFilesCount = files.ToList().Count;

            InvokeAsync(StateHasChanged);
        }
        protected string GetUploadUrl(string url) {
            return NavigationManager.ToAbsoluteUri(url).AbsoluteUri;
        }
    }
</DemoPageSectionComponent>
